#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "unistd.h"
#include "fcntl.h"
#include "sys/ipc.h"
#include "sys/msg.h"

#define SIZE 100

struct Buf{
    long type;
    char text[SIZE];
};


int main() {
    key_t key = ftok("/home/xupeng", 10);
    if (key < 0) {
        perror("ftok");
        return 2;
    }

    int msgid = msgget(key, IPC_CREAT | 0644);
    if (msgid < 0) {
        perror("msgid");
        return 2;
    }

    struct Buf bf;
    bzero(&bf, sizeof(bf));
    bf.type = 1;
    bf.text[0] = 0;
    strcpy(bf.text, "hello world");

    msgsnd(msgid, &bf, strlen(bf.text), 1);


    return 0;
}
